<?php

if (!isset($numcli) && !isset($_POST['nump']))
    {
	echo "
        <script language='javascript' type='text/javascript'>
        window.location.replace('index.php');
        </script>";
    }
else
    {
echo "<h2 style='padding:20px 0 0 0;'><a href='' id='intro'>Ajouter un Plan epargne-logement :</a></h2>";
if(!isset($_POST['nump']))
{
echo "
<center>
<form name='addcompte' method='post' action='index.php?p=creation_PEL' style='width:450px;';>
<p align='left'>Numero de client : $numcli <input type='hidden' name='nump' value='$numcli'>
<br>Solde du compte : <input type='text' name='solde' id='solde' size='15' value=''  />
<br>Montant initial : <input type='text' name='montantinitial' id='montantinitial' size='15' value=''  />
<br>Taux d'interet : <input type='text' name='tauxinteret' id='tauxinteret' size='15' value=''  />
<br>Montant des versements mensuels: <input type='text' name='montantversementmensuel' id='montantversementmensuel' size='15' value=''  />
<br>Seuil minimum : <input type='text' name='seuilmin' id='seuilmin' size='15' value=''  />
<br>Date echeance (format JJ-MM-AAAA) : <input type='text' name='dateecheance' id='dateecheance' size='15' value=''  />
</p>
<p align='right'><input type='submit' name='Submit' value='Creer le plan epargne-logement'></p>
</form>
</center>
";
}
else {
     if (is_numeric($_POST['solde']) && is_numeric($_POST['montantinitial']) && is_numeric($_POST['tauxinteret']) && is_numeric($_POST['montantversementmensuel']) && is_numeric($_POST['seuilmin']))
        {
        $creation="begin insert_PLAN_EPARGNE_LOGEMENT(".$_POST['nump'].",".$_POST['solde'].",".$_POST['montantinitial'].",".$_POST['tauxinteret'].",".$_POST['montantversementmensuel'].",".$_POST['seuilmin'].",'".$_POST['dateecheance']."'); end;";
        $sql->exe($creation);
        echo "Creation du produit effectue avec succes.";
        }
        else {echo "Veuillez entrer des chiffres...";}
     }
}
?>
